
<!DOCTYPE html>
<html>
<head>
    {include file="_Fragment/meta" /}
    <link rel="stylesheet" href="/static/pear/component/pear/css/pear.css" />
    <link rel="stylesheet" href="/static/pear/admin/css/admin.css" />
    <style>
        .hd-form-upload {
            width: 80px;
            height: 80px;
            display: inline-block;
            cursor: pointer;
        }

        .hd-form-upload input {
            display: none;
        }

        .hd-form-upload span {
            width: 80px;
            height: 80px;
            line-height: 80px;
            text-align: center;
            float: left;
            overflow: hidden;
            background-color: #ddd;
        }

        .hd-form-upload span img {
            width: 100%;
            display: inline;
            vertical-align: middle;
        }

        .hd-form-upload span i {
            width: 80px;
            height: 80px;
            float: left;
            position: relative;
        }

        .hd-form-upload  span i:before {
            content: "";
            border-top: 2px solid #bbb;
            position: absolute;
            top: 39px;
            left: 20px;
            right: 20px;
        }

        .hd-form-upload  span i:after {
            content: "";
            border-right: 2px solid #bbb;
            position: absolute;
            top: 20px;
            left: 39px;
            bottom: 20px;
        }
    </style>
</head>
<body class="pear-container">

<div class="layui-row">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form">
                <fieldset class="layui-elem-field layui-form" lay-filter="add">
                    <legend>基本信息</legend>
                    <div class="layui-field-box">
                        <div class="layui-form-item">
                            <label class="layui-form-label">标题(CN)</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" autocomplete="off" placeholder="请输入调研标题(CN), 最多200个字符" lay-verify="required" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">标题(EN)</label>
                            <div class="layui-input-block">
                                <input type="text" name="e_title" autocomplete="off" placeholder="请输入调研标题(EN), 最多200个字符" lay-verify="required" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">调研封面</label>
                            <div class="layui-input-block">
                                <label  class="hd-form-upload" id="image">
                                    <span id="thumb-banner-thumb">
                                        <i></i>
                                    </span>
                                </label>
                                <input type="hidden" id="banner_thumb" name="images" value=""/>
                            </div>
                            <p style="margin-left:130px;">
                                封面图尺寸为16:9
                            </p>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">课件分类</label>
                            <div class="layui-input-block" style="width: 50%">
                                <select name="cate_id" lay-verify="required">
                                    <option value="">请选择课件分类</option>
                                    {volist name="cate" id="vo"}
                                    <option value="{$vo.id}">{$vo.title}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">课件标签</label>
                            <div class="layui-input-block" style="width: 50%">
                                <select name="label_id" xm-select="select4" xm-select-skin="default" lay-verify="required">
                                    {volist name="label" id="vo"}
                                    <option value="{$vo.id}">{$vo.title}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">是否公开</label>
                            <div class="layui-input-block">
                                <input type="radio" name="open" value="1" title="公开" checked>
                                <input type="radio" name="open" value="2" title="非公开">
                            </div>
                            <div class="layui-form-mid layui-word-aux">Tips：公开课件可供所有有资源库权限的用户复制和引用。</div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">调研说明</label>
                            <div class="layui-input-block">
                                <textarea name="description" id="description" style="height: 200px;"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">调研结果</label>
                            <div class="layui-input-block">
                                <input type="radio" name="survey_result" value="1" title="展示" checked>
                                <input type="radio" name="survey_result" value="2" title="不展示">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">截止时间</label>
                            <div class="layui-input-block" style="width: 30%;">
                                <input type="text" name="end_time" id="date" autocomplete="off" placeholder="请选择截止日期" class="layui-input">
                            </div>
                            <p style="margin-left:130px;">
                                调研截止时间不设置，默认关联课程完成情况
                            </p>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">关联课程完成情况</label>
                            <div class="layui-input-block">
                                <input type="radio" class="ra" name="relation" value="1" title="关联" checked>
                                <input type="radio" class="ra1" name="relation" value="2" title="不关联">
                            </div>
                        </div>
                    </div>
                </fieldset>

                <fieldset class="layui-elem-field">
                    <legend>调研问题</legend>
                    <div class="layui-field-box">
                        <div class="subject">

                        </div>
                        <div class="an">
                            <button type="button" class="layui-btn" onclick="add_subject('0')">添加题目</button>
                        </div>
                    </div>
                </fieldset>
                <div class="layui-form-item layui-layout-admin" style="text-align: center">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;z-index: 1000 !important;">
                            <button class="layui-btn" lay-submit lay-filter="user-save">保存</button>
                        </div>

                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="/static/common/jquery-3.6.0.min.js"></script>
<script src="/static/pear/component/layui/layui.js"></script>
<script src="/static/pear/component/pear/pear.js"></script>

<script>
    layui.use(['jquery', 'form', 'laydate','croppers', 'tinymce', 'select'], function() {
        var $ = layui.$
            ,croppers = layui.croppers
            ,laydate = layui.laydate
            ,form = layui.form;
        let tinymce = layui.tinymce;
        let select = layui.select;

        select.render({
            placeholder: '请选择课件标签'
        });

        var description = tinymce.render({
            elem: "#description",
            height: 400,
            images_upload_url: "{:url('Pub/blob')}",
            form: {name:'file'}
        });

        laydate.render({
            elem: '#date'
            ,trigger: 'click'
            ,type: 'datetime'
            ,done: function(value, date, endDate){
                if (value != '') {
                    $('.ra1').prop('checked', true);
                } else {
                    $('.ra').prop('checked', true);
                }
                form.render();
            }
        });
        //创建一个Banner上传组件
        croppers.render({
            elem: '#image'
            //,saveW:750     //保存宽度
            //,saveH:768
            ,mark:16/9    //选取比例
            ,area:'850px'  //弹窗宽度
            ,url: "{:url('Pub/blob')}"   //图片上传接口返回和（layui 的upload 模块）返回的JOSN一样
            ,done: function(url){ //上传完毕回调
                $("#thumb-banner-thumb").html('<img src="'+ url + '" />');
                $("#banner_thumb").val(url);
            }
        });

        form.on('submit(user-save)', function(data) {
            var form = layui.form;
            var data = form.val('add');

            var content = description.getContent();
            data.description = '';
            data.description += content;

            var num = $(".subject > fieldset").length;
            var subject = [];
            for (var i = 0; i < num; i++) {
                var newA = i + 1;

                var rows = form.val('k'+newA);

                clas = ".option"+newA+" > div";
                var option_num = $(clas).length;
                var option = [];
                for (var ii = 0; ii < option_num; ii++) {

                    var nA = ii + 1;
                    var res = form.val(newA+'kk'+nA);
                    option.push(res);

                }
                rows['options']  = option;
                subject.push(rows);
            }
            let loading = layer.load();
            $.ajax({
                url: '/Courseware/saveSurvey',
                data: JSON.stringify({data:data, subject:subject}),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function(result) {
                    layer.close(loading);
                    if (result.status == 0) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    });
</script>

<script>
    var arr = ['0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20',
        '21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40',
        '41','42','43','44','45','46','47','48','49','50'];
    function Vf(arr,item){
        for(var i=0;i<arr.length;i++){
            if(arr[i] == item){
                return i;
            }
        }
    }
    function add_subject(key) {
        var newC = Vf(arr,key);
        if (newC >=50) {
            layer.msg('不能添加更多题目了', {icon: 7});return false;
        }
        var newA = arr[newC+1];
        var newB = "'"+newA+"'";
        var subject =
            '                        <fieldset class="layui-elem-field layui-form k'+newA+'" lay-filter="k'+newA+'">\n' +
            '                            <legend>\n' +
            '                                <span id="sn">问题【'+newA+'】</span>\n' +
            '                                <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" onclick="del_subject('+newB+')">删除此题</button>\n' +
            '                            </legend>\n' +
            '                            <div class="layui-field-box">\n' +
            '                                <div class="layui-row">\n' +
            '                                    <div class="layui-form-item">\n' +
            '                                        <div class="layui-input-block" style="display: flex">\n' +
            '                                            <textarea name="subject" placeholder="请输入题目, 最多1000个字符" lay-verify="required"  class="layui-textarea" style="width: 780px"></textarea>\n' +
            '                                            <div>\n' +
            '                                                 <button type="button" id="up'+newA+'" class="layui-btn">上传图片</button>\n' +
            '                                            </div>\n' +
            '                                        </div>\n' +
            '                            <div class="layui-input-block" id="t'+newA+'">\n' +
            '                            </div>\n' +
            '                                    </div>\n' +
            '                                    <div class="layui-form-item">\n' +
            '                                        <label class="layui-form-label">选项类型</label>\n' +
            '                                        <div class="layui-input-block" style="display: flex">\n' +
            '                                            <button type="button" class="layui-btn layui-btn-sm" id="'+newA+'" onclick="types(this,1)">单选</button>\n' +
            '                                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-border-green" id="'+newA+'" onclick="types(this,2)">多选</button>\n' +
            '                                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-border-green" id="'+newA+'" onclick="types(this,3)">开放式</button>\n' +
            '                                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary layui-border-green" id="'+newA+'" onclick="types(this,4)">打分项</button>\n' +
            '                                        </div>\n' +
            '                                        <span>Tip: 评分项类型的题目，有NA-10 共11个选项，选择NA 不计分，选择计分时，1~10分别代表1~10分。</span>\n' +
            '                                    </div>\n' +
            '                                    <div class="option'+newA+'">\n' +
            '                                       <div class="layui-form-item layui-form" lay-filter="'+newA+'kk1" >\n' +
            '                                           <label class="layui-form-label"><span>选项[1]</span></label>\n' +
            '                                           <div class="layui-input-block" style="display: flex">\n' +
            '                                               <input type="text" name="option" autocomplete="off" placeholder="请输入选项内容, 最多1000个字符" class="layui-input" style="width: 80%">\n' +
            '                                           <div>\n' +
            '                                                   <button type="button" id="'+newA+'upload1" class="layui-btn">上传图片</button>\n' +
            '                                           </div>\n' +
            '                                           </div>\n' +
            '                                           <div class="layui-input-block" id="'+newA+'tt1">\n' +
            '                                           </div>\n' +
            '                                       </div>\n' +
            '                                    </div>\n' +
            '                                    <div class="layui-form-item">\n' +
            '                                        <div class="layui-input-block xx'+newA+'" id="1">\n' +
            '                                            <button type="button" class="layui-btn" onclick="add_option(1,'+newA+')">添加选项</button>\n' +
            '                                        </div>\n' +
            '                                    </div>\n' +
            '                                    <div class="layui-form-item">\n' +
            '                                        <div class="layui-input-block">\n' +
            '                                            <button type="button" class="layui-btn q'+newA+'" id="'+newA+'" onclick="qt(this)">添加"其他"选项</button>\n' +
            '                                        </div>\n' +
            '                                    </div>\n' +
            '                                    <div class="qt'+newA+'">\n' +
            '                                    </div>\n' +
            '                                    <div class="dx'+newA+'">\n' +
            '                                    </div>\n' +
            '                                </div>\n' +
            '                            </div>\n' +
            '                        </fieldset>';

        $('.subject').append(subject);
        up(newA);
        uploads(newA,1);
        $('.an').html('<button type="button" class="layui-btn" onclick="add_subject('+newB+')">添加题目</button>');
    }



    function del_subject(key) {
        $('.k'+key).remove();
        var num = $(".subject > fieldset").length;
        for (var i = 0; i < num; i++) {
            var newA = i + 1;
            $('.subject').children('fieldset').eq(i).attr('class','layui-elem-field layui-form k'+newA);
            $('.subject').children('fieldset').eq(i).attr('lay-filter','k'+newA);
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(2).attr('class','option'+newA);
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(3).children('div').eq(0).attr('class','layui-input-block xx'+newA);
            var id = $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(3).children('div').eq(0).attr('id');
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(3).children('div').eq(0).html('<button type="button" class="layui-btn" onclick="add_option('+id+','+newA+')">添加选项</button>');
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(2).children('div').attr('id',newA);
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(1).children('div').children('button').attr('id',newA);
            var dx = 'dx'+newA;
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(6).attr('class',dx);
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(4).children('div').children('button').attr('id',newA);
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(4).children('div').children('button').attr('class','layui-btn q'+newA);
            var qt = 'qt'+newA;
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(5).attr('class',qt);


            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(0).children('div').eq(0).children('div').html(
                '<button type="button" id="up'+newA+'" class="layui-btn">上传图片</button>'
            );

            var t = 't'+newA;
            $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(0).children('div').eq(1).attr('id',t);




            var filter = $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(2).children('div').length;
            for (var f = 0; f < filter; f++) {
                var fA = f + 1;

                var filter1 = newA+'kk'+fA;
                $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(2).children('div').eq(f).attr('lay-filter',filter1);

            }

            var nums = $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(2).children('div').length;
            for (var ii = 0; ii < nums; ii++) {
                var nA = ii + 1;

                var upload = newA+'upload'+nA;
                var content =
                    '<button type="button" id="'+upload+'" class="layui-btn">上传图片</button>\n'
                $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(2).children('div').eq(ii).children('div').children('div').html(content);
                uploads(newA,nA);
            }

            var numss = $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(2).children('div').length;
            for (var iii = 0; iii < numss; iii++) {
                var nAA = iii + 1;

                var tt = newA+'tt'+nAA;
                $('.subject').children('fieldset').eq(i).children('div').children('div').children('div').eq(2).children('div').eq(iii).children('div').eq(1).attr('id', tt);
            }

            $('.subject').children('fieldset').children('legend').eq(i).html(
                ' <span id="sn">问题【'+newA+'】</span>\n' +
                ' <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" onclick="del_subject('+newA+')">删除此题</button>\n'
            );
            up(newA);
        }

        $('.an').html('<button type="button" class="layui-btn" onclick="add_subject('+num+')">添加题目</button>');

    }

    function up(key) {
        layui.use('upload', function(){
            var upload = layui.upload;
            upload.render({
                elem: '#up'+key
                ,url: "{:url('Pub/blob')}"
                ,accept:'images'
                ,acceptMime: 'image/*'
                ,exts:'jpeg|jpg|png'
                ,done: function(res){
                    if(res.code == 200){
                        $("#t"+key).html(
                            '                                <div style="display: flex">\n' +
                            '                                <label  class="hd-form-upload">\n' +
                            '                                    <span>\n' +
                            '                                        <img src="'+ res.data + '" />\n' +
                            '                                    </span>\n' +
                            '                                </label>\n' +
                            '                                <input type="hidden" name="images" value="'+ res.data + '"/>\n' +
                            '                                <button type="button" class="layui-btn layui-btn-xs layui-btn-radius layui-btn-danger" onclick="del_img(this)">删除</button>\n' +
                            '                            <p style="margin-left:130px;">建议图片大小为570*300px,否则可能导致图片变形\n' +
                            '                            </p>\n'+
                            '                                </div>'

                        );
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
        });

    }

    function del_img(i) {
        i.parentNode.remove();
    }

    function add_option(key, key1) {
        var newC = Vf(arr,key);
        if (newC >=50) {
            layer.msg('不能添加更多选项了', {icon: 7});return false;
        }
        var newA = arr[newC+1];
        var newB = ""+newA+"";

        var content =
            '                                       <div class="layui-form-item layui-form" lay-filter="'+key1+'kk'+newA+'" id="'+key1+'">\n' +
            '                                           <label class="layui-form-label"><span>选项['+newA+']</span></label>\n' +
            '                                           <div class="layui-input-block" style="display: flex">\n' +
            '                                               <input type="text" name="option" autocomplete="off" placeholder="请输入选项内容, 最多1000个字符" class="layui-input" style="width: 80%">\n' +
            '                                               <div>\n'+
            '                                                   <button type="button" id="'+key1+'upload'+newA+'" class="layui-btn">上传图片</button>\n' +
            '                                               </div>\n'+
            '                                               <button type="button" class="layui-btn layui-btn-danger" onclick="del_option(this)">删除选项</button>\n' +
            '                                           </div>\n' +
            '                                           <div class="layui-input-block" id="'+key1+'tt'+newA+'">\n' +
            '                                           </div>\n' +
            '                                       </div>\n';
        $('.option'+key1).append(content);
        uploads(key1,newA);
        $('.xx'+key1).attr('id',newB);
        $('.xx'+key1).html('<button type="button" class="layui-btn" onclick="add_option('+newB+','+key1+')">添加选项</button>');
    }

    function uploads(key1, key) {
        layui.use('upload', function(){
            var upload = layui.upload;
            upload.render({
                elem: '#'+key1+'upload'+key
                ,url: "{:url('Pub/blob',['path'=>'survey'])}"
                ,accept:'images'
                ,acceptMime: 'image/*'
                ,exts:'jpeg|jpg|png'
                ,done: function(res){
                    if(res.code == 200){

                        $('#'+key1+'tt'+key).html(
                            '                                <div style="display: flex">\n' +
                            '                                <label  class="hd-form-upload">\n' +
                            '                                    <span>\n' +
                            '                                        <img src="'+ res.data + '" />\n' +
                            '                                    </span>\n' +
                            '                                </label>\n' +
                            '                                <input type="hidden" name="option_images" value="'+ res.data + '"/>\n' +
                            '                                <button type="button" class="layui-btn layui-btn-xs layui-btn-radius layui-btn-danger" onclick="del_images(this)">删除</button>\n' +
                            '                                </div>'

                        );
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
        });

    }

    function del_images(i) {
        i.parentNode.remove();
    }
    function del_option(i) {
        var id = i.parentNode.parentNode.getAttribute('id');
        i.parentNode.parentNode.remove();
        var option = '.option'+id+' > div';
        var num = $(option).length;
        for (var i = 0; i < num; i++) {
            var newA = i + 1;

            var content =
                '<button type="button" id="'+id+'upload'+newA+'" class="layui-btn">上传图片</button>\n'

            $('.option'+id).children('div').eq(i).children('div').eq(0).children('div').html(content);

            var tt = id+'tt'+newA;
            $('.option'+id).children('div').eq(i).children('div').eq(1).attr('id', tt);
            $('.option'+id).children('div').eq(i).attr('lay-filter',id+'kk'+newA);
            $('.option'+id).children('div').children('label').eq(i).html(
                ' <span id="sn">选项['+newA+']</span>\n'
            );
            uploads(id,newA);
        }

        $('.xx'+id).attr('id',num);
        $('.xx'+id).html('<button type="button" class="layui-btn" onclick="add_option('+num+','+id+')">添加选项</button>');
    }
    function types(i,key) {
        var id = i.getAttribute('id');
        var cl = '.dx'+id;
        var pn = i.parentNode;
        pn.children[0].setAttribute('class', 'layui-btn layui-btn-sm layui-btn-primary layui-border-green');
        pn.children[1].setAttribute('class', 'layui-btn layui-btn-sm layui-btn-primary layui-border-green');
        pn.children[2].setAttribute('class', 'layui-btn layui-btn-sm layui-btn-primary layui-border-green');
        pn.children[3].setAttribute('class', 'layui-btn layui-btn-sm layui-btn-primary layui-border-green');
        i.setAttribute('class', 'layui-btn layui-btn-sm');
        if (key == 2) {
            var option = '.option'+id;
            $(option).css('display','block');
            $('.xx'+id).css('display','block');
            $('.q'+id).css('display','block');
            $(cl).html(
                '                                    <div class="layui-form-item">\n' +
                '                                        <div class="layui-inline">\n' +
                '                                            <label class="layui-form-label">答题选择数量</label>\n' +
                '                                            <div class="layui-input-inline">\n' +
                '                                                <input type="number" min="1" name="min" placeholder="至少选择数量" value="" autocomplete="off" class="layui-input">\n' +
                '                                            </div>\n' +
                '                                            <div class="layui-form-mid">-</div>\n' +
                '                                            <div class="layui-input-inline">\n' +
                '                                                <input type="number" min="1" name="max" placeholder="至多选择数量" value="" autocomplete="off" class="layui-input">\n' +
                '                                            </div>\n' +
                '                                        </div>\n' +
                '                                    </div>'
            );
        } else if(key == 1) {
            $(cl).html('');
            var option = '.option'+id;
            $(option).css('display','block');
            $('.xx'+id).css('display','block');
            $('.q'+id).css('display','block');
        } else if(key == 3){
            var option = '.option'+id;
            $(option).css('display','none');
            $('.xx'+id).css('display','none');
            $('.q'+id).css('display','none');
            $('.qt'+id).html('');
            $(cl).html(
                '                                    <div class="layui-form-item" style="display: flex">\n' +
                '                                        <div class="layui-inline">\n' +
                '                                            <label class="layui-form-label">答题字数范围</label>\n' +
                '                                            <div class="layui-input-inline" style="width: 100px;">\n' +
                '                                                <input type="number" min="1" name="character_min" placeholder="最小字数" value="0" autocomplete="off" class="layui-input">\n' +
                '                                            </div>\n' +
                '                                            <div class="layui-form-mid">-</div>\n' +
                '                                            <div class="layui-input-inline" style="width: 100px;">\n' +
                '                                                <input type="number" min="1" name="character_max" placeholder="最大字数" value="0" autocomplete="off" class="layui-input">\n' +
                '                                            </div>\n' +
                '                                        </div>\n' +
                '                                        <span>如果不填写，默认无字数限制</span>\n' +
                '                                    </div>\n' +
                '                                    <div class="layui-form-item"  style="display: flex">\n' +
                '                                        <div class="layui-inline">\n' +
                '                                            <label class="layui-form-label">答题框大小</label>\n' +
                '                                            <div class="layui-input-inline">\n' +
                '                                                <select name="height">\n' +
                '                                                    <option value="">设置高度</option>\n' +
                '                                                    <option value="1">高度1行</option>\n' +
                '                                                    <option value="2">高度2行</option>\n' +
                '                                                    <option value="3">高度3行</option>\n' +
                '                                                    <option value="4">高度4行</option>\n' +
                '                                                    <option value="5">高度5行</option>\n' +
                '                                                </select>\n' +
                '                                            </div>\n' +
                '                                        </div>\n' +
                '                                        <span>不设置高度，默认高3行</span>\n' +
                '                                    </div>'
            );
        } else {
            var option = '.option'+id;
            $(option).css('display','none');
            $('.xx'+id).css('display','none');
            $('.q'+id).css('display','none');
            $('.qt'+id).html('');
            $(cl).html(
                '                                    <div class="layui-form-item">\n' +
                '                                        <label class="layui-form-label">1分描述*</label>\n' +
                '                                        <div class="layui-input-block">\n' +
                '                                            <input type="text" name="one_intro" placeholder="请填写1分描述" max="10" autocomplete="off" class="layui-input">\n' +
                '                                       </div>\n' +
                '                                    </div>\n' +
                '                                    <div class="layui-form-item">\n' +
                '                                        <label class="layui-form-label">10分描述*</label>\n' +
                '                                           <div class="layui-input-block">\n' +
                '                                                <input type="text" name="ten_intro" placeholder="请填写10分描述" max="10" autocomplete="off" class="layui-input">\n' +
                '                                          </div>\n' +
                '                                    </div>'
            );
        }

        layui.use('form', function(){
            var form = layui.form;
            form.render();
        });
    }

    function qt(i) {
        var id = i.getAttribute('id');
        var qt = '.qt'+id;
        $(qt).html(
            '                                    <div class="layui-form-item">\n' +
            '                                        <label class="layui-form-label">选项名称</label>\n' +
            '                                        <div class="layui-input-block" style="display: flex">\n' +
            '                                            <input type="text" name="other" lay-verify="required" autocomplete="off" value="其他" class="layui-input" style="width: 80%">\n' +
            '                                            <button type="button" class="layui-btn layui-btn-danger" onclick="del_qt(this)">删除</button>\n' +
            '                                        </div>\n' +
            '                                    </div>'
        );
    }

    function del_qt(i) {
        i.parentNode.parentNode.remove();
    }
</script>
</body>
</html>

